package com.elitel.frame.web.jdp_common_category.controller;


import com.elitel.frame.main.entity.vo.JsonResult;
import com.elitel.frame.web.jdp_common_category.entity.JdpCommonCategory;
import com.elitel.frame.web.jdp_common_category.service.IJdpCommonCategoryService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.Map;

@RestController
@RequestMapping("jdpCommonCategory")
public class JdpCommonCategoryController {
    @Resource
    IJdpCommonCategoryService iJdpCommonCategoryService;

    @GetMapping("test")
    public String test(JdpCommonCategory record) {
        return "JdpCommonCategoryController " + LocalDateTime.now();
    }

    @PostMapping("add")
    public JsonResult insert(@RequestBody JdpCommonCategory record) {
        String aa = iJdpCommonCategoryService.insert(record);
        return JsonResult.builder().success(true).data(aa).build();
    }

    @PostMapping("update")
    public JsonResult update(@RequestBody JdpCommonCategory record) {
        String aa = iJdpCommonCategoryService.update(record);
        return JsonResult.builder().success(true).data(aa).build();
    }

        @GetMapping("deleteById")
    public JsonResult deleteById(String id) {
        String aa = iJdpCommonCategoryService.deleteById(id);
        return JsonResult.builder().success(true).data(aa).build();
    }

    @GetMapping("selectById")
    public JsonResult selectById(String id) {
        JdpCommonCategory aa = iJdpCommonCategoryService.selectById(id);
        return JsonResult.builder().success(true).data(aa).build();
    }

    @GetMapping("selectAll")
    public JsonResult selectAll(String name,Integer pageNum,Integer pageSize) {
        Map<String,Object> aa =  iJdpCommonCategoryService.selectAll(name,pageNum,pageSize);
        return JsonResult.builder().success(true).data(aa).build();
    }
}
